home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 November / Macworld (1999-11).dmg / Shareware World / Info / For Developers / Smile1.6.6.sea / Smile1.6.6 / Smile ƒ / Help files / Applets and droplets < prev    next >
Text File  |  1999-08-17  |  4KB  |  65 lines

  1. Applets and Droplets
  2.  
  3.  
  4. Getting started with applets
  5.  
  6. To make a droplet an "on open" handler must be included in the script. (The "on open" handler distinguishes a droplet from an applet.)
  7.  
  8. The following example illustrates the steps of making a droplet. Making an applet is similar, except an applet does not have an "on open" handler. Instead, an applet has a "run" (or unnamed) handler. Before starting the example, open a new script window. Select the menu "New script" ( N), in the "File" menu.
  9.  
  10. Enter the following into the new script window : 
  11.  
  12. on open ()
  13. display dialog "Making a droplet is fun!!!"
  14. end open
  15.  
  16. • Press the Enter key (in the numeric keypad), or click the "checkmark" button () of the script window, to compile. 
  17.  
  18. • Select "Save" ("File"menu). Be sure that the script window is the active window. 
  19.  
  20. • A dialog box will be presented. Choose "Application" in the "Format" pop-up menu.
  21.  
  22. • Enter "MyDroplet" (without quotes) and choose a destination.
  23.  
  24. Smile will then run and place the "MyDroplet" icon at the chosen destination.
  25.  
  26. Smile is "droplet" aware, and senses the presence of the "on open" handler. Note that the droplet icon has a distinctive, down-pointing arrow. 
  27.  
  28. • Now try "MyDroplet" by using drag-and-drop. Drop another icon onto "MyDroplet" and observe the operation as it executes. 
  29.  
  30. Droplets must include a "on-open" handler, but they may also have a "run" (or unnamed) handler which will run when the icon is double-clicked - like applets. This can be a very handy method for the user to include a help message that can serve as a reminder of the function of the droplet. The help message may include what you need to know about what the droplet expects you to drop on it (one/several files/folders of what type....). An example of making such a droplet is presented below. 
  31.  
  32. Before starting the next example, open a new script window "New script" ( N), in the "File" menu.
  33.  
  34. Enter the following into the new script window : 
  35. ----------------------------
  36. display dialog "Drop an icon to get the value of pi."
  37. on open ()
  38.     display dialog "Pi = " & pi
  39. end open
  40. ----------------------------
  41.  
  42. • Press Enter-key (or click "checkmark"  of script window) to compile. 
  43.  
  44. • Select "Save" ("File"menu). Be sure that the script window is the active window. 
  45.  
  46. • A dialog box will be presented. Choose "Application" in the "Format" pop-up menu.
  47.  
  48. • Enter "MyDroplet" (without quotes) and choose a destination.
  49.  
  50. Smile will then run and place the "MyDroplet" icon at the chosen destination.
  51.  
  52. When you double-click the droplet icon, a dialog box will be presented telling the function of the droplet. When an icon is dropped on the droplet icon, the "on-open" handler will run. 
  53.  
  54.  
  55. Stay-open applications
  56.  
  57. To make a stay-open applet, choose "Stay-open application" from the Format pop-up menu of the "Save" dialog. A stay-open applet remains in the background, instead of quitting, after it has ended execution of its "run" (or unnamed) handler. A stay-open applet can be used for instance as a server application which receives requests from other servers. It can also check permanently for some condition. In this case, it must have an "on idle" handler.
  58.  
  59.  
  60. Run-only applications
  61.  
  62. The pop-up menu of the "Save" dialog also allows to save applets as run-only. When you save an applet / droplet as run-only, you save only the executable code that it contains, without the text of the source script. In other words, no one will ever be able to see the script you have saved. It can only be run. Of course this may induce data loss if the source script is not saved elsewhere.
  63.  
  64. ========================================================
  65.